/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.inventory.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "CUSTOMER_DETAILS", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "CustomerDetails.findAll", query = "SELECT c FROM CustomerDetails c"), @NamedQuery(name = "CustomerDetails.findByDetailsId", query = "SELECT c FROM CustomerDetails c WHERE c.detailsId = :detailsId"), @NamedQuery(name = "CustomerDetails.findByCustomerContact", query = "SELECT c FROM CustomerDetails c WHERE c.customerContact = :customerContact"), @NamedQuery(name = "CustomerDetails.findByCustomerMobile", query = "SELECT c FROM CustomerDetails c WHERE c.customerMobile = :customerMobile"), @NamedQuery(name = "CustomerDetails.findByShopAddress", query = "SELECT c FROM CustomerDetails c WHERE c.shopAddress = :shopAddress"),
    @NamedQuery(name = "CustomerDetails.recordCount", query = "SELECT COUNT(c) FROM CustomerDetails c")})
public class CustomerDetails implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DETAILS_ID", nullable = false)
    private Integer detailsId;
    @Column(name = "CUSTOMER_CONTACT", length = 20)
    private String customerContact;
    @Column(name = "CUSTOMER_MOBILE", length = 20)
    private String customerMobile;
    @Column(name = "SHOP_ADDRESS", length = 100)
    private String shopAddress;
    @JoinColumn(name = "CUSTOMER_ID", referencedColumnName = "CUSTOMER_ID")
    @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.ALL})
    private Customer customerId;
    @JoinColumn(name = "ROUTE_ID", referencedColumnName = "ROUTE_ID", nullable = false)
    @ManyToOne(optional = false, fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
    private Route routeId;

    public CustomerDetails() {
    }

    public CustomerDetails(Integer detailsId) {
        this.detailsId = detailsId;
    }

    public Integer getDetailsId() {
        return detailsId;
    }

    public void setDetailsId(Integer detailsId) {
        this.detailsId = detailsId;
    }

    public String getCustomerContact() {
        return customerContact;
    }

    public void setCustomerContact(String customerContact) {
        this.customerContact = customerContact;
    }

    public String getCustomerMobile() {
        return customerMobile;
    }

    public void setCustomerMobile(String customerMobile) {
        this.customerMobile = customerMobile;
    }

    public String getShopAddress() {
        return shopAddress;
    }

    public void setShopAddress(String shopAddress) {
        this.shopAddress = shopAddress;
    }

    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }

    public Route getRouteId() {
        return routeId;
    }

    public void setRouteId(Route routeId) {
        this.routeId = routeId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detailsId != null ? detailsId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CustomerDetails)) {
            return false;
        }
        CustomerDetails other = (CustomerDetails) object;
        if ((this.detailsId == null && other.detailsId != null) || (this.detailsId != null && !this.detailsId.equals(other.detailsId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.CustomerDetails[detailsId=" + detailsId + "]";
    }
}
